<template>
	<el-dialog :title="title" v-model="previewDialogVisible" width="70%" :append-to-body="true">
		<my-page-component ref="pageComponent"></my-page-component>
	</el-dialog>
</template>

<script>
	import utils from '@/utils/utils.js';
	import {
		getPageData
	} from '@/utils/pageUtils.js';
	export default {
		name: "searchDialog",
		data() {
			return {
				previewDialogVisible: false,
				componentModel: {},
				searchComponent: {},
				title:"查询",
			}
		},
		inject:['children'],
		mounted() {
			this.children.push(this);
		},
		methods: {
			setVisible(visible, searchComponent) {
				if (searchComponent != undefined) {
					this.searchComponent = searchComponent;
				}
				var that = this;
				this.previewDialogVisible = visible;
				if (visible) {
					this.$nextTick(function() {
						that.loadPage();
					});
				}
			},
			loadPage() {
				var pageComponent=utils.getPageComponent(this.searchComponent);
				var parentCode=pageComponent.componentModel.code;
				var parentData=getPageData(pageComponent,this.searchComponent.children);
				var dataJsonString=encodeURIComponent(JSON.stringify(parentData));
				var data={};
				data["parentCode"]=parentCode;
				data["parentData"]=dataJsonString;
				data["searchComponent"]=this.searchComponent.componentModel.id;
				this.$refs.pageComponent.navigatePage(this.searchComponent.componentModel.pageCode,data,true);
			},
			setSelectedValue(value) {
				this.searchComponent.setSelectedValue(value);
			}
		}
	}
</script>

<style>
</style>
